package com.gamecollection.fish.model.obj;

import com.gamecollection.fish.utils.GameUtils;

import java.awt.*;

/**
 * 我方鱼类
 */
public class MyFish extends GameObj {
    
    // 移动速度
    private int speed = 25;
    // 等级
    private int level = 2;
    
    public MyFish() {
        super(700, 500, 50, 50, GameUtils.MyFishimg_L);
    }
    
    @Override
    public void update() {
        // 处理移动逻辑
        if (GameUtils.UP) {
            y -= speed;
        }
        if (GameUtils.DOWN) {
            y += speed;
        }
        if (GameUtils.LEFT) {
            x -= speed;
            img = GameUtils.MyFishimg_L;
        }
        if (GameUtils.RIGHT) {
            x += speed;
            img = GameUtils.MyFishimg_R;
        }
        
        // 边界检测
        if (x < 0) x = 0;
        if (x > 1440 - width) x = 1440 - width;
        if (y < 0) y = 0;
        if (y > 900 - height) y = 900 - height;
    }
    
    @Override
    public void paintSelf(Graphics g) {
        g.drawImage(img, x, y, width + GameUtils.count, height + GameUtils.count, null);
    }
    
    /**
     * 获取碰撞矩形
     */
    public Rectangle getRec() {
        return new Rectangle(x, y, width + GameUtils.count, height + GameUtils.count);
    }
    
    // Getter和Setter方法
    public int getSpeed() {
        return speed;
    }
    
    public void setSpeed(int speed) {
        this.speed = speed;
    }
    
    public int getLevel() {
        return level;
    }
    
    public void setLevel(int level) {
        this.level = level;
    }
} 